|
The man or boy test was proposed by computer scientist Donald Knuth as a means of evaluating implementations of the ALGOL 60 programming language. The aim of the test was to distinguish compilers that correctly implemented "recursion and non-local references" from those that did not. ==Knuth's example== begin real procedure A(k, x1, x2, x3, x4, x5); value k; integer k; begin real procedure B; begin k := k - 1; B := A := A(k, B, x1, x2, x3, x4); end; if k <= 0 then A := x4 + x5 else B; end; outreal(A(10, 1, -1, -1, 1, 0)); end; This creates a tree of ''B'' call frames that refer to each other and to the containing ''A'' call frames, each of which has its own copy of ''k'' that changes every time the associated ''B'' is called. Trying to work it through on paper is probably fruitless, but the correct answer is −67, despite the fact that in the original paper Knuth conjectured it to be −121. The survey paper by Charles H. Lindsey mentioned in the references contains a table for different starting values. Even modern machines quickly run out of stack space for larger values of k, which are tabulated below ().〔(See Performance and Memory on the Rosetta Code Man or Boy Page )〕 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Man or boy test」の詳細全文を読む スポンサード リンク
|